package com.atguigu.pratice;

import java.util.Scanner;

public class YangHuiTriangle2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        if(n==1||n==2){
            System.out.println(-1);
            return;
        }
        int m=(n-2)%4;
        switch (m){
            case 1:
                System.out.println(2);
                break;
            case 2:
                System.out.println(3);
                break;
            case 3:
                System.out.println(2);
                break;
            case 0:
                System.out.println(4);
                break;
        }
    }
}
